package com.huike.clues.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.huike.clues.domain.SysDictType;
import com.huike.clues.mapper.SysDictTypeMapper;
import com.huike.clues.service.ISysDictTypeService;
import com.huike.common.core.domain.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;

@Service
public class SysDictTypeServiceImpl implements ISysDictTypeService {

    @Autowired
    private SysDictTypeMapper sysDictTypeMapper;

    @Override
    public List<SysDictType> list(SysDictType sysDictType) {
        List<SysDictType> list = sysDictTypeMapper.list(sysDictType);
        return list;
    }


    @Override
    public SysDictType getDetailsById(Long dictId) {
        return sysDictTypeMapper.getDetailsById(dictId);
    }

    @Override
    public void add(SysDictType sysDictType) {
        //校验字典名称和字典类型是否已经存在
        if (sysDictTypeMapper.checkDictTypeUnique(sysDictType.getDictType())>0) {
            throw new RuntimeException("字典类型已经存在");
        }
        sysDictTypeMapper.add(sysDictType);
    }

}
